package com.openfeign.controller;

import com.example.comment.config.Result;
import com.example.comment.entity.Payment;
import com.openfeign.service.PaymentOpenFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author kuang
 * @Date 2021/8/15 23:42
 */
@RestController
@Slf4j
@RequestMapping("/consumer")
public class OpenFeignController {

    @Resource
    private PaymentOpenFeign paymentOpenFeign;

    @GetMapping("/payment/get/{id}")
    public Result<Payment> getPaymentById(@PathVariable("id")Long id){
        return paymentOpenFeign.getPaymentById(id);
    }

    @GetMapping(value = "/feign/timeout")
    public String timeOut() {
//        feign客户端默认等待1秒钟
        return paymentOpenFeign.timeOut();
    }

}
